/*
 * @Author: your name
 * @Date: 2021-10-11 19:17:42
 * @LastEditTime: 2021-10-11 19:40:16
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\1.5贪心\P1223\2main.cpp
 */
#include<iostream>
using namespace std;
#include<stdlib.h>
#include<time.h>
#include<iomanip>

typedef struct People
{
    int index;
    int wait_time;
}people;

void quickSort(people** p,int low,int high);

void insertSort(people** p,int n);

int main(){
    int n;
    cin >> n;
    //malloc
    people** p = (people**)malloc(sizeof(people*)*(n+2));
    if(!p) exit(-1);
    for(int i=1; i<=n; i++){
        p[i] = (people*)malloc(sizeof(people));
        if(!p[i]) exit(-1);
        p[i]->index = i;
        cin >> p[i]->wait_time;
    }
    //sort
    //quickSort(p,1,n);
    insertSort(p,n);
    double sum = 0;
    for(int i=1; i<=n; i++){
        cout << p[i]->index << " ";
        sum += (n-i)*p[i]->wait_time;
    }

    cout << endl << fixed << setprecision(2) << sum/n << endl;
    //free
    p[0] = NULL;
    for(int i=1; i<=n; i++){
        if(p[i]) free(p[i]); 
    }
    if(p) free(p);
}

void quickSort(people** p,int low,int high)
{
    if(low < high){
        srand(time(NULL));
        int tem = rand()%(high-low+1)+low;
        people* pivot = p[tem];
        p[tem] = p[low];
        p[low] = pivot;

        int l = low,r = high;
        while(l < r){
            while(l < r && p[r]->wait_time > pivot->wait_time) r--;
            if(l < r) p[l++] = p[r];
            while(l < r && p[l]->wait_time < pivot->wait_time) l++;
            if(l < r) p[r--] = p[l];
        }
        p[l] = pivot;
        quickSort(p,low,l-1);
        quickSort(p,l+1,high);
    }
}

void insertSort(people** p,int n)
{
    int i,j;
    for(i=2; i<=n; i++){
        if(p[i]->wait_time < p[i-1]->wait_time){
            p[0] = p[i];
            for(j=i-1; p[j]->wait_time > p[0]->wait_time; j--){
                p[j+1] = p[j];
            }
            p[j+1] = p[0];
        }
    }
}